package cc.niushuai.projects.misportchange.stepchange.job;

import cc.niushuai.projects.misportchange.stepchange.bean.MiUser;
import cc.niushuai.projects.misportchange.stepchange.service.StepChangeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Random;

/**
 * @ClassName: ChangeJob
 * @Description: TODO
 * @Author: 忆尘不散
 * @Date: 2023/12/1 17:17
 * @Version 1.0
 **/
@Component
@Slf4j
public class ChangeJob {

    @Autowired
    private StepChangeService stepChangeService;

    @Scheduled(cron = "0 0 17 * * ?")
    public void autoChange() {
        MiUser user = new MiUser();
        user.setUsername("18539908730");
        user.setPassword("yudaxin1996");
        Random random = new Random();
        long step = random.nextInt(20000) + 20000L;
        user.setStep(step);
        user.setStepType("MI");
        try {
            String change = stepChangeService.change(user);
            log.info("自动执行修改步数任务" + change);
        } catch (Exception e) {
            log.error("数据异常", e);
        }
    }
}
